import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web

from tornado.options import define, options

names = {'d':[{'name':'darkofday', 'id':1}, {'name':'lynn', 'id':2}, 
    {'name':'lynnhome', 'id':3}, {'name':'lynn123', 'id':4}, 
    {'name':'dark', 'id':5}, {'name':'lynnhome...', 'id':6}]}

define("port", default=8888, help="run on the given port", type=int)

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.render("home.html")

class GetListHandler(tornado.web.RequestHandler):
    def get(self):
        global names
        prefix = self.get_argument("prefix", None)
        filtered = list(i for i in names if i['name'].startswith('lynn'))
        dic = dict({'d':filtered})
        self.write(dic)
